<template>
  <div>
    <div>
      <span>支付设置</span>
    </div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="pay_id" label="编号"></el-table-column>
      <el-table-column prop="pay_way" label="支付方式"> </el-table-column>
      <el-table-column property="menusstate" label="状态">
        <template slot-scope="scope">
          <el-switch
            active-color=" #ff4949"
            inactive-color="#13ce66"
            v-model="scope.row.menusstate"
          >
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作" style="text-align: center">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="handleDel(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="block juzhong"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData: [
        {
          id: "",
          way: "",
          state: "",
        },
      ],
      page:1,
      count: 5,
      editData: {
        pay_way: "",
        pay_id: "",
      },
      totalData: [],
      dialogVisible: false,
    };
  },
  methods: {
    //删除该条数据
    handleDel(i) {
       let index = this.tableData.findIndex(
        (item) => item.pay_id === i.pay_id
      );
      this.tableData.splice(index, 1);
       
      

      // this.$alert("确认删除", {
      //   title: "支付订单删除",
      //   callback: () => {
      //     console.log(data.pay_id);
      //     this.$axios({
      //       url: "/pay/deldata",
      //       method: "post",
      //       data: {
      //         id: data.pay_id,
      //       },
      //     }).then((res) => {
      //       console.log(res.data.code);
      //       if (res.data.code == 200) {
      //         this.getpay();
      //       }
      //     });
      //   },
      // });
    },
    //获取后台数据
    getpay() {
      this.$axios({
        url: "/pay/getpay",
      }).then((res) => {
        this.totalData = res.data.data;
        //将拿到的数据给到表格绑定的数组
        this.tableData = [...this.totalData];
        console.log(this.tableData);
      });
    },
  },
  created() {
    this.getpay();
  },
};
</script>
<style lang="less" scope>
.juzhong {
  text-align: center;
  margin-top: 10px;
}
</style>